package com.kj.xuyuan.chat;

import android.content.Context;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.LinearLayout;

import com.kj.xuyuan.R;
import com.kj.xuyuan.base.BaseFragment;

import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import butterknife.BindView;
import butterknife.OnClick;
import io.rong.imkit.RongIM;
import io.rong.imkit.config.ConversationListBehaviorListener;
import io.rong.imkit.conversationlist.ConversationListFragment;
import io.rong.imkit.conversationlist.model.BaseUiConversation;
import io.rong.imlib.model.Conversation;

public class MyConversationListFragment extends BaseFragment {
    @BindView(R.id.ll_my_friend)
    LinearLayout llMyFriend;
    @BindView(R.id.ll_friend_request)
    LinearLayout llFriendRequest;
    @BindView(R.id.ll_my_request)
    LinearLayout llMyRequest;
    @BindView(R.id.container)
    FrameLayout container;

    @Override
    protected int setLayoutResourceID() {
        return R.layout.fragment_conversation_list;
    }

    @Override
    protected void initView() {
        ConversationListFragment conversationListFragment = new ConversationListFragment();
        FragmentManager manager = getActivity().getSupportFragmentManager();
        FragmentTransaction transaction = manager.beginTransaction();
        transaction.replace(R.id.container, conversationListFragment);
        transaction.commit();

        RongIM.setConversationListBehaviorListener(new ConversationListBehaviorListener() {
            @Override
            public boolean onConversationPortraitClick(Context context, Conversation.ConversationType conversationType, String s) {
                return false;
            }

            @Override
            public boolean onConversationPortraitLongClick(Context context, Conversation.ConversationType conversationType, String s) {
                return false;
            }

            @Override
            public boolean onConversationLongClick(Context context, View view, BaseUiConversation baseUiConversation) {
                return false;
            }

            @Override
            public boolean onConversationClick(Context context, View view, BaseUiConversation baseUiConversation) {
                ChatActivity.actionStar(context, baseUiConversation.mCore.getConversationType(), baseUiConversation.mCore.getTargetId());
                return true;
            }
        });
    }

    @Override
    protected void initData() {

    }

    @OnClick({R.id.ll_my_friend, R.id.ll_friend_request, R.id.ll_my_request})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.ll_my_friend:
                break;
            case R.id.ll_friend_request:
                break;
            case R.id.ll_my_request:
                break;
        }
    }
}
